{% extends 'stark/layout.html' %}

{% block content %}

<form method="post" action="?type=edit">
    {% csrf_token %}
    {{ edit_per_formset.management_form }}
    <div class="bs-example" data-example-id="table-within-panel">
    <div class="panel panel-default">
      <!-- Default panel contents -->
      <div class="panel-heading">
        <i class="fa fa-th-list" aria-hidden="true"></i> 待更新权限列表
        <button class="btn btn-primary btn-xs" style="padding: 2px 8px; margin: -3px; float: right">
            <i class="fa fa-refresh" aria-hidden="true"></i>
            更新
        </button>
      </div>

      <!-- Table -->
      <table class="table">
        <thead>
          <tr>
            <th>序号</th>
            <th>名称</th>
            <th>URL</th>
            <th>别名</th>
            <th>所属菜单</th>
            <th>父权限</th>
          </tr>
        </thead>
        <tbody>
          {% for form in edit_per_formset %}
            <tr>
                <td>{{ forloop.counter }}</td>
                {% for field in form %}
                    {% if forloop.counter == 1 %}
                        {{ field }}
                    {% else %}
                        <td>{{ field }}<span style="color: red">{{ field.errors.0 }}</span></td>
                    {% endif %}
                {% endfor %}
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
</div>
</form>

<form method="post" action="?type=add">
    {% csrf_token %}
    {{ add_per_formset.management_form }}
    <div class="bs-example" data-example-id="table-within-panel">
    <div class="panel panel-default">
      <!-- Default panel contents -->
      <div class="panel-heading">
        <i class="fa fa-th-list" aria-hidden="true"></i> 待新建权限列表
        <button class="btn btn-primary btn-xs" style="padding: 2px 8px; margin: -3px; float: right">
            <i class="fa fa-plus-circle" aria-hidden="true"></i>
            新建
        </button>
      </div>

      <!-- Table -->
      <table class="table">
        <thead>
          <tr>
            <th>序号</th>
            <th>名称</th>
            <th>URL</th>
            <th>别名</th>
            <th>所属菜单</th>
            <th>父权限</th>
          </tr>
        </thead>
        <tbody>
          {% for form in add_per_formset %}
            <tr>
                <td>{{ forloop.counter }}</td>
                {% for field in form %}
                    <td>{{ field }}<span style="color: red">{{ field.errors.0 }}</span></td>
                {% endfor %}
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
</div>
</form>

<div class="bs-example" data-example-id="table-within-panel">
    <div class="panel panel-default">
      <!-- Default panel contents -->
      <div class="panel-heading">
        <i class="fa fa-th-list" aria-hidden="true"></i> 待删除权限列表
      </div>

      <!-- Table -->
      <table class="table">
        <thead>
          <tr>
            <th>序号</th>
            <th>名称</th>
            <th>URL</th>
            <th>别名</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
            {% for row in del_per_list %}
            <tr>
                <td>{{ forloop.counter }}</td>
                <td>{{ row.title }}</td>
                <td>{{ row.url }}</td>
                <td>{{ row.name }}</td>
                <td>
                    <a style="color: #d9534f;" href="{% url 'rbac_multi_permissions_del' pid=row.id %}">
                        <i class="fa fa-trash-o">
                        </i>
                    </a>
                </td>
            </tr>
            {% endfor %}
        </tbody>
      </table>
    </div>
</div>

{% endblock %}